/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.order.controller.point;

import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.order.model.*;
import com.medusa.gruul.order.service.IPointOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 提货点端
 *
 * @author alan
 * @date 2019 /11/13 20:14
 */
@RestController
@RequestMapping("/point")
@Api(tags = "提货点端订单接口")
public class PointOrderController {
    @Resource
    private IPointOrderService pointOrderService;


    /**
     * Gets history order page.
     *
     * @param dto the dto
     * @return the history order page
     */
    @ApiOperation("根据提货点ID查询提货点历史订单")
    @GetMapping("/history/order")
    public Result<PageUtils<HistoryOrderVo>> getHistoryOrderPage(QueryPointHistoryOrderDto dto) {
        PageUtils<HistoryOrderVo> page = pointOrderService.getHistoryOrderPage(dto);
        return Result.ok(page);
    }

    /**
     * Gets user overview list.
     *
     * @param pointId the point id
     * @param keyword the keyword
     * @return user overview list
     */
    @ApiOperation("用户概况列表")
    @GetMapping("/user/overview")
    public Result<List<UserOverviewVo>> getUserOverviewList(@RequestParam(value = "pointId") Long pointId,
                                                            @RequestParam(value = "keyword", required = false) String keyword) {
        List<UserOverviewVo> list = pointOrderService.getUserOverviewPage(pointId, keyword);
        return Result.ok(list);
    }

    /**
     * Gets order page.
     *
     * @param dto the dto
     * @return order page
     */
    @ApiOperation("用户订单列表")
    @GetMapping("/user/order")
    public Result<PageUtils<SimpleOrderVo>> getOrderPage(QueryUserOrderDto dto) {
        PageUtils<SimpleOrderVo> page = pointOrderService.getOrderPage(dto);
        return Result.ok(page);
    }

    /**
     * Verify order result.
     *
     * @param orderId the order id
     * @return the result
     */
    @ApiOperation("核销订单")
    @PutMapping("/verify/{orderId}")
    public Result verifyOrder(@PathVariable(value = "orderId") Long orderId) {
        pointOrderService.verifyOrder(orderId);
        return Result.ok();
    }


}
